package com.genexususa.eo.bing.data.results;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.BatchError;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "AdGroupAdsResult")
public class GxElementsAdGroupsResult extends GxGeneralResult {
    @XmlElement(name = "TrackingId")
    public String specificTrackingId;
    @XmlElement(name = "GxAdGroupId")
    public long gxAdGroupId;
    @XmlElement(name = "BingAdGroupId")
    public long bingAdGroupId;
    @XmlElementWrapper(name = "ElementResultCollection")
    @XmlElement(name = "ElementResult")
    public GxIdResult[] elementResults;

    public GxElementsAdGroupsResult() {
        super();
    }

    public GxIdResult[] getElementResults() {
        return elementResults;
    }

    public void createElementCollection(int elementQuantity) {
        this.elementResults = new GxIdResult[elementQuantity];
    }

    public void addElementResult(int index, long gxId, long id) {
        this.elementResults[index] = new GxIdResult(gxId, id);
    }

    public void addElementResult(int index, long gxId) {
        this.elementResults[index] = new GxIdResult(gxId);
    }

    public void setSpecificTrackingId(String trackingId) {
        this.specificTrackingId = trackingId;
    }

    public void setGxAdGroupId(long gxAdGroupId) {
        this.gxAdGroupId = gxAdGroupId;
    }

    public void setBingAdGroupId(long bingAdGroupId) {
        this.bingAdGroupId = bingAdGroupId;
    }

    public void addBatchError(BatchError error) {
        this.hasError = true;
        this.elementResults[error.getIndex()].addBatchError(error);
    }
}
